<template>
  <div>
    <div style="display: flex; justify-content: space-between">
      <div>
        <el-input
                :disabled="showAdvanceSearchView"
                size="small"
                style="width: 300px; margin-right: 10px"
                placeholder="请输入内容"
                prefix-icon="el-icon-search"
                v-model="keyword">
        </el-input>
        <el-button size="small" type="primary" :disabled="showAdvanceSearchView" icon="el-icon-search">搜索</el-button>
        <el-button size="small" type="primary" @click="showAdvanceSearchView = !showAdvanceSearchView">
          <i :class="showAdvanceSearchView?'fa fa-angle-double-up':'fa fa-angle-double-down'" aria-hidden="true"></i>
          高级搜索
        </el-button>
      </div>
      <div>
        <el-upload
                :show-file-list="false"
                :before-upload="beforeUpload"
                :on-success="onSuccess"
                :on-error="onError"
                :disabled="importDataDisabled"
                style="display: inline-flex;margin-right: 8px"
                action="/api/employee/basic/import"
                multiple>
          <el-button :disabled="importDataDisabled" size="small" type="success" :icon="importDataBtnIcon">
            {{importDataBtnText}}
          </el-button>
        </el-upload>
        <el-button size="small" type="success" icon="el-icon-download" @click="exportData">导出数据</el-button>
        <el-button size="small" type="primary" icon="el-icon-plus" @click="showAddEmpView">添加员工</el-button>
      </div>
    </div>
    <transition name="slide-fade">
      <div v-show="showAdvanceSearchView" style="border: 1px solid #409eff; border-radius: 5px; box-sizing: border-box; padding: 5px; margin: 10px 0px;">
        <el-row>
          <el-col :span="5">
            政治面貌：
            <el-select style="width: 150px" v-model="searchValue.politicId" size="mini" placeholder="请选择">
              <el-option
                      v-for="item in politicss"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
              </el-option>
            </el-select>
          </el-col>
          <el-col :span="4">
            民族：
            <el-select style="width: 150px" v-model="searchValue.nationId" size="mini" placeholder="请选择">
              <el-option
                      v-for="item in nations"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
              </el-option>
            </el-select>
          </el-col>
          <el-col :span="4">
            职位：
            <el-select style="width: 150px" v-model="searchValue.posId" size="mini" placeholder="请选择">
              <el-option
                      v-for="item in poss"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
              </el-option>
            </el-select>
          </el-col>
          <el-col :span="4">
            职称：
            <el-select style="width: 150px" v-model="searchValue.jobLevelId" size="mini" placeholder="请选择">
              <el-option
                      v-for="item in jobLevels"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
              </el-option>
            </el-select>
          </el-col>
          <el-col :span="7">
            聘用形式：
            <el-radio-group v-model="searchValue.engageForm">
              <el-radio label="劳动合同">劳动合同</el-radio>
              <el-radio label="劳务合同">劳务合同</el-radio>
            </el-radio-group>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="5">
            所属部门：
            <el-popover
                    placement="right"
                    title="请选择部门"
                    width="200"
                    trigger="manual"
                    v-model="popVisible2">
              <el-tree default-expand-all :data="departments" :props="defaultProps"
                       @node-click="searchViewHandleNodeClick"
                       :expand-on-click-node="false"></el-tree>
              <div slot="reference"
                   style="width: 147px;display: inline-flex;font-size: 13px;border: 1px solid #dedede;height: 26px;border-radius: 5px;cursor: pointer;align-items: center;padding-left: 8px;box-sizing: border-box;margin-left: 3px;margin-top: 3px"
                   class="inputDemName"
                   @click="showDepView2">
                {{inputDepName}}
              </div>
            </el-popover>
          </el-col>
          <el-col :span="10">
            入职日期：
            <el-date-picker
                    size="mini"
                    style="margin-top: 3px"
                    v-model="searchValue.beginDateScope"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期">
            </el-date-picker>
          </el-col>
          <el-col :span="5" :offset="4">
            <el-button size="mini" @click="showAdvanceSearchView = false">取消</el-button>
            <el-button size="mini" icon="el-icon-search" type="primary" @click="initEmps('advanced')">搜索</el-button>
          </el-col>
        </el-row>

      </div>
    </transition>

    <div>
      <el-table
              ref="multipleTable"
              :data="emps"
              border=""
              stripe
              style="width: 100%;margin-top: 10px"
              @selection-change="handleSelectionChange">
        <el-table-column
                type="selection"
                width="55">
        </el-table-column>
        <el-table-column
                prop="name"
                label="姓名"
                fixed
                width="95">
        </el-table-column>
        <el-table-column
                prop="workID"
                label="工号"
                width="95">
        </el-table-column>
        <el-table-column
                prop="gender"
                label="性别"
                width="55">
        </el-table-column>
        <el-table-column
                prop="birthday"
                label="出生日期"
                width="105">
        </el-table-column>
        <el-table-column
                prop="idCard"
                label="身份证号码"
                width="180">
        </el-table-column>
        <el-table-column
                prop="wedlock"
                label="婚姻状况"
                width="55">
        </el-table-column>
        <el-table-column
                prop="nation.name"
                label="民族"
                width="55">
        </el-table-column>
        <el-table-column
                prop="nativePlace"
                label="籍贯"
                width="95">
        </el-table-column>
        <el-table-column
                prop="politicsstatus.name"
                label="政治面貌"
                width="95">
        </el-table-column>
        <el-table-column
                prop="email"
                label="电子邮件"
                width="150">
        </el-table-column>
        <el-table-column
                prop="phone"
                label="电话号码"
                width="120">
        </el-table-column>
        <el-table-column
                prop="address"
                label="联系地址"
                width="200">
        </el-table-column>
        <el-table-column
                prop="department.name"
                label="所属部门"
                width="95">
        </el-table-column>
        <el-table-column
                prop="position.name"
                label="职位"
                width="95">
        </el-table-column>
        <el-table-column
                prop="jobLevel.name"
                label="职称"
                width="120">
        </el-table-column>
        <el-table-column
                prop="engageForm"
                label="聘用形式"
                width="95">
        </el-table-column>
        <el-table-column
                prop="tiptopDegree"
                label="最高学历"
                width="95">
        </el-table-column>
        <el-table-column
                prop="specialty"
                label="专业"
                width="120">
        </el-table-column>
        <el-table-column
                prop="school"
                label="毕业院校"
                width="95">
        </el-table-column>
        <el-table-column
                prop="beginDate"
                label="入职日期"
                width="105">
        </el-table-column>
        <el-table-column
                prop="conversionTime"
                label="转正日期"
                width="105">
        </el-table-column>
        <el-table-column
                prop="beginContract"
                label="合同起始日期"
                width="105">
        </el-table-column>
        <el-table-column
                prop="endContract"
                label="合同截止日期"
                width="105">
        </el-table-column>
        <el-table-column
                prop="contractTerm"
                label="合作期限"
                width="55">
        </el-table-column>
        <el-table-column
                label="操作"
                fixed="right"
                width="200">
          <template slot-scope="scope">
            <el-button style="padding: 3px" size="small" @click="showUpdateEmpView(scope.row)">编辑</el-button>
            <el-button style="padding: 3px" type="primary" size="small">查看高级资料</el-button>
            <el-button style="padding: 3px" type="danger" size="small" @click="doDeleteEmp(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div style="display: flex;justify-content: center">
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                layout="total, sizes, prev, pager, next, jumper, ->,total,slot"
                :total="total">
        </el-pagination>
      </div>
    </div>
    <el-dialog
            :title="title"
            :visible.sync="dialogVisible"
            width="80%">
      <div>
        <el-form :model="emp" :rules="rules" ref="empForm">
          <el-row>
            <el-col :span="6">
              <el-form-item label="姓名：" prop="name">
                <el-input size="mini" style="width: 150px" prefix-icon="el-icon-edit" v-model="emp.name"
                          placeholder="请输入员工姓名"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="性别：" prop="genger">
                <el-radio-group v-model="emp.gender">
                  <el-radio label="男">男</el-radio>
                  <el-radio label="女">女</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="出生日期：" prop="birthday">
                <el-date-picker
                        style="width: 150px"
                        size="mini"
                        value-format="yyyy-MM-dd"
                        v-model="emp.birthday"
                        type="date"
                        placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="政治面貌：" prop="politicId">
                <el-select style="width: 200px" v-model="emp.politicId" size="mini" placeholder="请选择">
                  <el-option
                          v-for="item in politicss"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="民族：" prop="nationId">
                <el-select style="width: 150px" v-model="emp.nationId" size="mini" placeholder="请选择">
                  <el-option
                          v-for="item in nations"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="籍贯：" prop="nativePlace">
                <el-input size="mini" style="width: 150px" prefix-icon="el-icon-edit" v-model="emp.nativePlace"
                          placeholder="籍贯"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="电子邮箱：" prop="email">
                <el-input size="mini" style="width: 150px" prefix-icon="el-icon-edit" v-model="emp.email"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="联系地址：" prop="address">
                <el-input size="mini" style="width: 200px" prefix-icon="el-icon-edit" v-model="emp.address"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="职位：" prop="posId">
                <el-select style="width: 150px" v-model="emp.posId" size="mini" placeholder="请选择">
                  <el-option
                          v-for="item in poss"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="职称：" prop="jobLevelId">
                <el-select style="width: 150px" v-model="emp.jobLevelId" size="mini" placeholder="请选择">
                  <el-option
                          v-for="item in jobLevels"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="所属部门：" prop="departmentId">
                <el-popover
                        placement="right"
                        title="请选择部门"
                        width="200"
                        trigger="manual"
                        v-model="popVisible">
                  <el-tree default-expand-all :data="departments" :props="defaultProps" @node-click="handleNodeClick"
                           :expand-on-click-node="false"></el-tree>
                  <div slot="reference"
                       class="inputDemName"
                       @click="showDepView">
                    {{inputDepName}}
                  </div>
                </el-popover>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="电话号码：" prop="phone">
                <el-input size="mini" style="width: 200px" v-model="emp.phone" prefix-icon="el-icon-edit"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="工号：" prop="workID">
                <el-input size="mini" style="width: 150px" disabled v-model="emp.workID"
                          prefix-icon="el-icon-edit"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="学历：" prop="tiptopDegree">
                <el-select style="width: 150px" v-model="emp.tiptopDegree" size="mini" placeholder="请选择">
                  <el-option
                          v-for="item in tiptopDegrees"
                          :key="item"
                          :label="item"
                          :value="item">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="毕业院校：" prop="school">
                <el-input size="mini" style="width: 150px" v-model="emp.school" prefix-icon="el-icon-edit"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="专业名称：" prop="specialty">
                <el-input size="mini" style="width: 200px" v-model="emp.specialty"
                          prefix-icon="el-icon-edit"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="入职日期：" prop="beginDate">
                <el-date-picker
                        style="width: 150px"
                        size="mini"
                        value-format="yyyy-MM-dd"
                        v-model="emp.beginDate"
                        type="date"
                        placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="转正日期：" prop="conversionTime">
                <el-date-picker
                        style="width: 150px"
                        size="mini"
                        value-format="yyyy-MM-dd"
                        v-model="emp.conversionTime"
                        type="date"
                        placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="合同起始日期：" prop="beginContract">
                <el-date-picker
                        style="width: 150px"
                        size="mini"
                        value-format="yyyy-MM-dd"
                        v-model="emp.beginContract"
                        type="date"
                        placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="合同终止日期：" prop="endContract">
                <el-date-picker
                        style="width: 150px"
                        size="mini"
                        value-format="yyyy-MM-dd"
                        v-model="emp.endContract"
                        type="date"
                        placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="专业名称：" prop="idCard">
                <el-input size="mini" style="width: 200px" v-model="emp.idCard" prefix-icon="el-icon-edit"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="聘用形式：" prop="engageForm">
                <el-radio-group v-model="emp.engageForm">
                  <el-radio label="劳动合同">劳动合同</el-radio>
                  <el-radio label="劳务合同">劳务合同</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="婚姻状况：" prop="wedlock">
                <el-radio-group v-model="emp.wedlock">
                  <el-radio label="已婚">已婚</el-radio>
                  <el-radio label="未婚">未婚</el-radio>
                  <el-radio label="离异">离异</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="submit">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: "EmpBasic",
    data() {
      return {
        // 高级搜索字段
        searchValue: {
          politicId: null,
          nationId: null,
          jobLevelId: null,
          posId: null,
          engageForm: null,
          departmentId: null,
          // 入职时间，以数组形式保存入职时间，和离职时间
          beginDateScope: null
        },
        importDataBtnText: '导入数据',
        importDataDisabled: false,
        importDataBtnIcon: 'el-icon-upload2',
        dialogVisible: false,
        keyword: '',
        showAdvanceSearchView: false,
        multipleSelection: [],
        emps: [],
        total: 0,
        size: 10,
        page: 0,
        title: '',
        emp: {
          name: "cenrc",
          gender: "男",
          birthday: "1990-01-01",
          idCard: "610122199001011256",
          wedlock: "已婚",
          nationId: 1,
          nativePlace: "陕西",
          politicId: 13,
          email: "laowang@qq.com",
          phone: "18565558897",
          address: "深圳市南山区",
          departmentId: 8,
          jobLevelId: 9,
          posId: 29,
          engageForm: "劳动合同",
          tiptopDegree: "本科",
          specialty: "信息管理与信息系统",
          school: "深圳大学",
          beginDate: "2018-01-01",
          workState: "在职",
          workID: "00000001",
          contractTerm: 1.0,
          conversionTime: null,
          notworkDate: null,
          beginContract: "2018-01-01",
          endContract: "2019-01-01",
          workAge: null
        },
        politicss: [],
        nations: [],
        jobLevels: [],
        departments: [],
        poss: [],
        tiptopDegrees: ['博士', '硕士', '本科', '大专', '高中', '初中', '小学'],
        allDeps: [],
        popVisible: false,
        popVisible2: false,
        inputDepName: '所属部门',
        defaultProps: {
          children: 'children',
          label: 'name'
        },
        rules: {
          name: [{required: true, message: '请输入用户名', trigger: 'blur'}],
          gender: [{required: true, message: '请输入性别', trigger: 'blur'}],
          birthday: [{required: true, message: '请输入出生日期', trigger: 'blur'}],
          idCard: [{required: true, message: '请输入身份证号码', trigger: 'blur'}, {
            pattern: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
            message: '身份证号码格式不正确',
            trigger: 'blur'
          }],
          wedlock: [{required: true, message: '请输入婚姻状况', trigger: 'blur'}],
          nationId: [{required: true, message: '请输入您组', trigger: 'blur'}],
          nativePlace: [{required: true, message: '请输入籍贯', trigger: 'blur'}],
          politicId: [{required: true, message: '请输入政治面貌', trigger: 'blur'}],
          email: [{required: true, message: '请输入邮箱地址', trigger: 'blur'}, {
            type: 'email',
            message: '邮箱格式不正确',
            trigger: 'blur'
          }],
          phone: [{required: true, message: '请输入电话号码', trigger: 'blur'}],
          address: [{required: true, message: '请输入员工地址', trigger: 'blur'}],
          departmentId: [{required: true, message: '请输入部门名称', trigger: 'blur'}],
          jobLevelId: [{required: true, message: '请输入职称', trigger: 'blur'}],
          posId: [{required: true, message: '请输入职位', trigger: 'blur'}],
          engageForm: [{required: true, message: '请输入聘用形式', trigger: 'blur'}],
          tiptopDegree: [{required: true, message: '请输入学历', trigger: 'blur'}],
          specialty: [{required: true, message: '请输入专业', trigger: 'blur'}],
          school: [{required: true, message: '请输入毕业院校', trigger: 'blur'}],
          beginDate: [{required: true, message: '请输入入职日期', trigger: 'blur'}],
          workState: [{required: true, message: '请输入工作状态', trigger: 'blur'}],
          workID: [{required: true, message: '请输入工号', trigger: 'blur'}],
          contractTerm: [{required: true, message: '请输入合同期限', trigger: 'blur'}],
          conversionTime: [{required: true, message: '请输入转正日期', trigger: 'blur'}],
          notworkDate: [{required: true, message: '请输入离职日期', trigger: 'blur'}],
          beginContract: [{required: true, message: '请输入合同起始日期', trigger: 'blur'}],
          endContract: [{required: true, message: '请输入合同结束日期', trigger: 'blur'}],
          workAge: [{required: true, message: '请输入工龄', trigger: 'blur'}],
        }
      }
    },
    methods: {
      // 高级搜索：所属部门
      searchViewHandleNodeClick(data) {
        console.log(data);
        this.inputDepName = data.name;
        this.searchValue.departmentId = data.id;
        this.popVisible2 = !this.popVisible2;

      },
      // 导入失败钩子函数
      onError() {
        this.importDataBtnText = '导入数据';
        this.importDataBtnIcon = 'el-icon-upload2';
        this.importDataDisabled = false;
      },
      // 导入成功钩子函数
      onSuccess() {
        this.importDataBtnText = '导入数据';
        this.importDataBtnIcon = 'el-icon-upload2';
        this.importDataDisabled = false;
        this.initEmps()
      },
      // 导入数据之前钩子函数
      beforeUpload() {
        this.importDataBtnText = '正在导入';
        this.importDataBtnIcon = 'el-icon-loading';
        this.importDataDisabled = true;
      },
      // 导出数据
      exportData() {
        window.open('/api/employee/basic/export', '_parent');
      },
      // 更新、添加操作综合处理
      submit() {
        if (this.emp.id == '' || this.emp.id == null) {
          this.doAddEmp()
        } else {
          this.doUpdateEmp()
        }
      },
      // 更新操作
      doUpdateEmp() {
        this.putRequest("/employee/basic/", this.emp).then(resp => {
          if (resp) {
            this.empinfo();
            this.dialogVisible = false
            this.initEmps();
          }
        })
      },
      // 展示更新页面
      showUpdateEmpView(row) {
        console.log(row);
        this.title = "更新员工";
        this.emp = row;
        this.initPos();
        this.inputDepName = row.department.name
        this.dialogVisible = true;
      },
      // 删除操作
      doDeleteEmp(row) {
        this.$confirm('此操作将永久删除' + row.name + ', 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.deleteRequest("/employee/basic/" + row.id).then(resp => {
            if (resp) {
              this.initEmps();
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
      doAddEmp() {
        this.$refs['empForm'].validate(valid => {
          if (valid) {
            this.postRequest("/employee/basic/", this.emp).then(resp => {
              if (resp) {
                this.empinfo();
                this.dialogVisible = false
                this.initEmps();
              }
            });
          }
        })

      },
      // 初始化员工添加数据
      empinfo() {
        this.emp = {
          name: "",
          gender: "",
          birthday: "",
          idCard: "",
          wedlock: "",
          nationId: 1,
          nativePlace: "",
          politicId: 13,
          email: "",
          phone: "",
          address: "",
          departmentId: null,
          jobLevelId: 9,
          posId: 29,
          engageForm: "",
          tiptopDegree: "",
          specialty: "",
          school: "",
          beginDate: "",
          workID: "",
          contractTerm: 2,
          conversionTime: "",
          notworkDate: null,
          beginContract: "",
          endContract: "",
          workAge: null
        }
      },
      // 获取最新员工工号
      initMaxWorkID() {
        this.getRequest("/employee/basic/maxWorkId").then(resp => {
          if (resp) {
            this.emp.workID = resp.obj;
          }
        })
      },
      // 所属部门树展示
      showDepView() {
        this.popVisible = !this.popVisible;
      },
      showDepView2() {
        this.popVisible2 = !this.popVisible2;
      },
      // 处理所属部门数据
      handleNodeClick(data) {
        this.inputDepName = data.name;
        this.emps.departmentId = data.id;
        this.popVisible = !this.popVisible;
      },
      // 初始化职位数据
      initPos() {
        this.getRequest("/employee/basic/positon").then(resp => {
          if (resp) {
            this.poss = resp;
          }
        })
      },
      // 初始化部分不变的选择菜单
      initData() {
        // 初始化政治面貌列表
        if (!window.sessionStorage.getItem("politicss")) {
          this.getRequest("/employee/basic/politics").then(resp => {
            if (resp) {
              this.politicss = resp;
              window.sessionStorage.setItem("politicss", JSON.stringify(resp))
            }
          })
        } else {
          this.politicss = JSON.parse(window.sessionStorage.getItem("politicss"))
        }
        // 初始化民族列表
        if (!window.sessionStorage.getItem("nations")) {
          this.getRequest("/employee/basic/nation").then(resp => {
            if (resp) {
              this.nations = resp;
              window.sessionStorage.setItem("nations", JSON.stringify(resp))
            }
          })
        } else {
          this.nations = JSON.parse(window.sessionStorage.getItem("nations"))
        }
        // 初始化职称列表
        if (!window.sessionStorage.getItem("jobLevels")) {
          this.getRequest("/employee/basic/joblevel").then(resp => {
            if (resp) {
              this.jobLevels = resp;
              window.sessionStorage.setItem("jobLevels", JSON.stringify(resp))
            }
          })
        } else {
          this.jobLevels = JSON.parse(window.sessionStorage.getItem("jobLevels"))
        }
        // 初始化所属部门列表
        if (!window.sessionStorage.getItem("departments")) {
          this.getRequest("/employee/basic/department").then(resp => {
            if (resp) {
              this.departments = resp;
              window.sessionStorage.setItem("departments", JSON.stringify(resp))
            }
          })
        } else {
          this.departments = JSON.parse(window.sessionStorage.getItem("departments"))
        }

      },
      // 显示添加用户对话框
      showAddEmpView() {
        this.title = '添加员工';
        this.initMaxWorkID();
        this.dialogVisible = true;
      },
      // 分页处理:获取 size
      handleSizeChange(val) {
        this.size = val;
        this.initEmps()
      },
      // 分页处理:获取 page
      handleCurrentChange(val) {
        this.page = val;
        this.initEmps()
      },
      //
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      // 初始化员工数据
      initEmps(type) {
        let url = "/employee/basic/?page=" + this.page + "&size=" + this.size;
        if (type && type == 'advanced') {
          if (this.searchValue.politicId){
            url += '&politicId=' + this.searchValue.politicId;
          }
          if (this.searchValue.nationId){
            url += '&nationId=' + this.searchValue.nationId;
          }
          if (this.searchValue.jobLevelId){
            url += '&jobLevelId=' + this.searchValue.jobLevelId;
          }
          if (this.searchValue.posId){
            url += '&posId=' + this.searchValue.posId;
          }
          if (this.searchValue.engageForm){
            url += '&engageForm=' + this.searchValue.engageForm;
          }
          if (this.searchValue.departmentId){
            url += '&departmentId=' + this.searchValue.departmentId;
          }
          if (this.searchValue.beginDateScope){
            url += '&beginDateScope=' + this.searchValue.beginDateScope;
          }
        }else {
          url += '&name=' + this.keyword;
        }
          this.getRequest(url).then(resp => {
            if (resp) {
              this.emps = resp.data;
              this.total = resp.total;
            }
          })
      }
    },
    mounted() {
      this.initEmps();
      this.initData();
      this.initPos();
    }
  }
</script>

<style>
  .inputDemName {
    width: 150px;
    display: inline-flex;
    font-size: 13px;
    border: 1px solid #dedede;
    height: 26px;
    border-radius: 4px;
    cursor: pointer;
    align-items: center;
    padding-left: 8px;
    box-sizing: border-box;
  }
  /* 可以设置不同的进入和离开动画 */
  /* 设置持续时间和动画函数 */
  .slide-fade-enter-active {
    transition: all .8s ease;
  }

  .slide-fade-leave-active {
    transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
  }

  .slide-fade-enter, .slide-fade-leave-to
    /* .slide-fade-leave-active for below version 2.1.8 */
  {
    transform: translateX(10px);
    opacity: 0;
  }
</style>